//:C06:ep_6_6.c -- PI.
#include <stdio.h>
#include <math.h>

int main(void)
{
    int sum1 = 1;
    float n = 1.0, tmp = 1, pi = 0;
    while(fabs(tmp) > 1e-6)
    {
        pi += tmp;
        n = n + 2;
        sum1 = -sum1;
        tmp = sum1 / n;
    }
    pi = pi * 4;
    printf("pi = %10.6f\n", pi);
}